/**
 * Created by alan on 2017/4/27.
 * 水库基本信息
 */
Ext.define('Admin.view.baseInfo.reservoirBaseInfo', {
	extend: 'Ext.container.Container',
	xtype: 'reservoirBaseInfo',
	requires: [
		'Admin.store.baseInfo.ReservoirBaseInfo'
	],
	//起别名
	alias: 'reservoirBaseInfo',
	controller: 'reservoirBaseController',
	userCLs: 'big-100 small-100',
	margin: 7,
	bodyPadding: 7,
	layout: {
		type: 'vbox',
		align: 'stretch' //拉伸使其充满整个父容器
	},
	height: 200,
	autoLoad: true,
	items: [{
		xtype: 'panel',
		height: 50,
		items: [{
			tbar: [
				//				{
				//					xtype: "textfield",
				//					maxWidth: 220,
				//					fieldLabel: "水库名称",
				//					labelWidth: 60,
				//					reference: "resNm"
				//				},
				{
					xtype: "combobox",
					maxWidth: 220,
					fieldLabel: "水库名称",
					reference: "resNm",
					displayField: 'resNm',
					queryMode: 'local',
					valueField: 'resNm',
					triggerAction: 'all',
					anyMatch: true,
					labelWidth: 60,
					listeners: {
						added: function(combo) {
							var _that = this;
							var store = Ext.create("Ext.data.Store", {
								autoLoad: true,
								proxy: {
									type: "ajax",
									url: config.URL + "/szy/info/ddsBRes/list",
									extraParams: {
										river: config.RIVER
									},
									reader: {
										type: 'json',
										rootProperty: 'list',
										totalProperty: 'count'
									}
								}
							});
							combo.setStore(store);
						}
					}
				},
				{
					xtype: "button",
					text: "查询",
					iconCls: 'x-fa  fa-file-o',
					handler: 'check',
					margin: '0 10 0 10',
					// style: 'background-color:#108ee9; border-radius:4px;-webkit-border-radius: 4px;',
					style: 'border-radius:4px;-webkit-border-radius: 4px;'
				}
			],
			margin: '0 0 10 0'
		}, ]
	}, {
		xtype: 'gridpanel',
		title: '水库基础信息',
		flex: 1,
		scrollable: true,
		reference: 'reservoirGrid',
		columns: [{
				header: '水库代码',
				dataIndex: 'resCd',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '水库名称',
				dataIndex: 'resNm',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '所在地',
				dataIndex: 'loc',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '集水面积(km&sup2;)',
				dataIndex: 'catA',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '设计洪水位(m)',
				dataIndex: 'desFz',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '总库容(亿m&sup3;)',
				dataIndex: 'totV',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '调洪库容(亿m&sup3;)',
				dataIndex: 'frscV',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '正常蓄水位(m)',
				dataIndex: 'normWz',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '校核洪水位(m)',
				dataIndex: 'cfZ',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '兴利库容(亿m&sup3;)',
				dataIndex: 'utilV',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '防洪限制水位(m)',
				dataIndex: 'fsZ',
				/** editor: 'textfield' ,*/
				align: 'center',
				width: 120
			},
			{
				header: '防洪限制水位库容(亿m&sup3;)',
				dataIndex: 'fsZV',
				/** editor: 'textfield' ,*/
				align: 'center',
				width: 150
			},
			{
				header: '死水位(m)',
				dataIndex: 'deadZ',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '死库容(亿m&sup3;)',
				dataIndex: 'deadV',
				/** editor: 'textfield' ,*/
				align: 'center'
			},
			{
				header: '最小下泄流量(m&sup3;/s)',
				dataIndex: 'minDisc',
				/** editor: 'textfield' ,*/
				align: 'center',
				width: 120
			},
			// {header: '操作', dataIndex: 'operate', /** editor: 'textfield' ,*/align:'center',},
			{
				header: '操作',
				dataIndex: 'operate',
				/** editor: 'textfield' ,*/
				align: 'center',
				xtype: 'actioncolumn',
				items: [{
					xtype: 'button',
					text: '水位库容',
					tooltip: '水位库容曲线',
					margin: '0 10 0 10',
					// style: 'background-color:#108ee9; border-radius:4px;-webkit-border-radius: 4px;',
					iconCls: 'x-fa fa-bar-chart-o',
					style: 'border-radius:4px;-webkit-border-radius: 4px;',
					handler: 'toChart'
				}, {
					xtype: 'button',
					text: '下泄尾水',
					tooltip: '下泄尾水曲线',
					iconCls: 'x-fa fa-bar-chart-o',
					style: 'border-radius:4px;-webkit-border-radius: 4px;',
					handler: 'toChartTail'
				}]
			}
		],
		store: {
			type: 'reservoirBaseInfo'
		},
		bbar: {
			xtype: 'pagingtoolbar',
			displayInfo: true,
			displayMsg: "显示从第{0}条数据到第{1}条数据，共{2}条数据",
			emptyMsg: "没有记录",
		},
		stripeRows: true,
		columnLines: true,
		plugins: {
			ptype: 'cellediting',
			clicksToEdit: 1
		}
	}]
})

//水位库容曲线
Ext.define('Admin.view.baseInfo.DdsBResChart', {
	extend: 'Ext.panel.Panel',
	xtype: 'ddsBResChart',
	alias: 'ddsBResChart',
	controller: 'ddsBResChartController',
	layout: 'column',
	region: 'center',
	items: [{
			xtype: 'grid',
			height: '100%',
			border: true,
			margin: '0 0 10 0',
			bind: {
				store: 'ddsDStz'
			},
			reference: 'historyGrid', //添加“reference”配置到表格并用lookupReference方法获取表格组件
			stripeRows: true, //斑马纹效果
			loadMask: true, //loading效果
			multiSelect: false //允许用户在列表中同时选择多个
		}, {
			columnWidth: 1,
			tbar: [{
					xtype: "textfield",
					maxWidth: 220,
					fieldLabel: "水位",
					labelWidth: 40,
					reference: "v0"
				}, {
					xtype: "textfield",
					maxWidth: 220,
					fieldLabel: "库容",
					labelWidth: 40,
					reference: "v1"
				},
				{
					xtype: "button",
					text: "查询",
					iconCls: 'x-fa  fa-file-o',
					handler: 'find',
					margin: '0 10 0 10',
					// style: 'background-color:#108ee9; border-radius:4px;-webkit-border-radius: 4px;',
					style: 'border-radius:4px;-webkit-border-radius: 4px;'
				}
			],
			margin: '0 0 10 0'
		},
		{
			width: '80%',
			xtype: 'component',
			columnWidth: 2 / 3,
			margin: '0 0 10 0',
			border: 1,
			padding: '10 0 10 0',
			style: {
				borderColor: '#ccc',
				borderStyle: 'solid'
			},
			html: '<div class="tab-inner-content-chart row"><div class="col-md-12"><div id="myChart" style="height: 580px;"></div></div></div>'
		},
		{
			xtype: 'grid',
			columnWidth: 1 / 3,
			reference: 'ddsBResChartGrid',
			width: '20%',
			minHeight: 600,
			height: 600,
			border: true,
			margin: '0 20 20 20',
			columns: [{
					header: '水位(m)',
					dataIndex: 'v0',
					/** editor: 'textfield' ,*/
					align: 'center',
					width: '50%',
				},
				{
					header: '库容(百万m<sup>3</sup>)',
					dataIndex: 'v1',
					/** editor: 'textfield' ,*/
					align: 'center',
					width: '48%',
				}
			],
			store: {
				type: 'ddsBResChart'
			},
			stripeRows: true, //斑马线
			columnLines: true, //行线
			plugins: {
				ptype: 'cellediting',
				clicksToEdit: 1
			},
			listeners: {
				afterrender: 'initLoad'
			}
		}
	]
});
//下泄尾水
Ext.define('Admin.view.baseInfo.DdsBResTailChart', {
	extend: 'Ext.panel.Panel',
	xtype: 'ddsBResTailChart',
	alias: 'ddsBResTailChart',
	controller: 'ddsBResTailChartController',
	layout: 'column',
	region: 'center',
	items: [{
			xtype: 'grid',
			height: '100%',
			border: true,
			margin: '0 0 10 0',
			bind: {
				store: 'ddsBResTailChart'
			},
			reference: 'historyGrid', //添加“reference”配置到表格并用lookupReference方法获取表格组件
			stripeRows: true, //斑马纹效果
			loadMask: true, //loading效果
			multiSelect: false //允许用户在列表中同时选择多个
		}, {
			columnWidth: 1,
			tbar: [{
					xtype: "textfield",
					maxWidth: 220,
					fieldLabel: "水位",
					labelWidth: 40,
					reference: "v0"
				}, {
					xtype: "textfield",
					maxWidth: 220,
					fieldLabel: "流量",
					labelWidth: 40,
					reference: "v1"
				},
				{
					xtype: "button",
					text: "查询",
					iconCls: 'x-fa  fa-file-o',
					handler: 'find',
					margin: '0 10 0 10',
					// style: 'background-color:#108ee9; border-radius:4px;-webkit-border-radius: 4px;',
					style: 'border-radius:4px;-webkit-border-radius: 4px;'
				}
			],
			margin: '0 0 10 0'
		},
		{
			width: '80%',
			xtype: 'component',
			columnWidth: 2 / 3,
			margin: '0 0 10 0',
			border: 1,
			padding: '10 0 10 0',
			style: {
				borderColor: '#ccc',
				borderStyle: 'solid'
			},
			html: '<div class="tab-inner-content-chart row"><div class="col-md-12"><div id="myChart" style="height: 580px;"></div></div></div>'
		},
		{
			xtype: 'grid',
			columnWidth: 1 / 3,
			reference: 'ddsBResTailChartGrid',
			width: '20%',
			minHeight: 600,
			height: 600,
			border: true,
			margin: '0 20 20 20',
			columns: [{
					header: '水位(m)',
					dataIndex: 'v0',
					/** editor: 'textfield' ,*/
					align: 'center',
					width: '50%'
				},
				{
					header: '流量(百万m<sup>3</sup>)',
					dataIndex: 'v1',
					/** editor: 'textfield' ,*/
					align: 'center',
					width: '48%'
				}
			],
			store: {
				type: 'ddsBResTailChart'
			},
			stripeRows: true, //斑马线
			columnLines: true, //行线
			plugins: {
				ptype: 'cellediting',
				clicksToEdit: 1
			},
			listeners: {
				afterrender: 'initLoad'
			}
		}
	]
});